<template>
	<view class="TodoList">
		<template v-for="(item, index) in list">
			<todo-list-item :item='item' :key="index" :getListData="getListData"></todo-list-item>
		</template>
		<view class="oprate">
			<view class="leftBtn fajc">
				全部删除
			</view>
			<view class="create fajc" @click="createTodoItem">
				<image class="icon" src="../../static/icon/xinjianrenwu.svg"></image>
			</view>
			<view class="rightBtn fajc">
				全部完成
			</view>
		</view>
	</view>
</template>

<script>
	import TodoListItem from './TodoListItem.vue';
	export default {
		components: {
			TodoListItem
		},
		data() {
			return {
				list: [
					{
						content: '带爸爸妈妈去很多地方吃很多好吃的',
						status: 'done',
						start_time: 1675418400000
					},
					{
						content: '带糖糖去很多地方吃很多好吃的',
						status: 'todo',
						start_time: 1675418400000
					},
					{
						content: '带老婆去很多地方吃很多好吃的',
						status: 'doing',
						start_time: 1675418400000
					}
				]
			}
		},
		onLoad() {
			this.getListData();
		},
		onBackPress(e) {
			uni.redirectTo({
				url: "/pages/index/index"
			})
			return true;
		},
		methods: {
			async getListData() {
				const [err, res] = await uni.request({
					url: this.BASE_URL + '/getTodoList'
				})
				console.log(res.data);
				this.list = res.data.data;
			},
			createTodoItem() {
				uni.navigateTo({
					url: "/pages/TodoEdit/TodoEdit"
				})
				// this.list.push({
				// 	content: '123123123',
				// 	status: 'todo'
				// })
			}
		}
	}
</script>

<style lang="scss" scoped>
	.TodoList {
		.oprate {
			position: fixed;
			bottom: 0;
			left: 0;
			height: 100rpx;
			width: 100%;
			// border-top: 1px solid #e4e6eb;
			display: flex;
			align-items: center;
			justify-content: space-evenly;
			
			.leftBtn {
				height: 100%;
				flex: 1;
				border-top: 1px solid #e4e6eb;
			}
			
			.rightBtn {
				height: 100%;
				flex: 1;
				border-top: 1px solid #e4e6eb;
			}
			
			.create {
				margin-top: -100rpx;
				width: 100rpx;
				height: 100rpx;
				border: 2px solid #e4e6eb;
				border-radius: 50%;
				box-shadow: 0px 3px 5px #e4e6eb;
			}
		}
	}
</style>
